package component.firstPage.Login;
import java.util.Scanner;

//一次封装为 doLogin 作用 登录交互
public class Login {
    private static String loggedInUserId = null;  // 存储当前登录用户的ID
    
    public static String getLoggedInUserId() {
        return loggedInUserId;
    }
    
    public static boolean doLogin() {
        int count = 1;
        Scanner myscanner = new Scanner(System.in);
        while (count <= 10) {
            System.out.println("-------------欢迎使用 小云线上医疗系统-------------");
            System.out.println("请用户登录该系统");
            System.out.println("请输入账号:");
            String useraccount = myscanner.nextLine();
            System.out.println("请输入密码:");
            String userpassword = myscanner.nextLine();
            
            String userId = _Login.login(useraccount, userpassword);
            if (userId != null) {
                loggedInUserId = userId;  // 存储登录用户ID
                return true;
            }
            System.out.println("账户名或密码错误 请重新输入... ...");
            count++;
        }
        return false;
    }
    //打印函数  二次封装
    public static void LoginPrint(){
        boolean result = doLogin();
        if (result) {
            System.out.println("登录成功");
        } else {
            System.out.println("多次尝试登录失败");
        }
    }

}
